package com.example.geckohurricanes;

public class User {
	
	private String uname, pword;
	private int admin;
	private long id;
	
	public User(String user, String pass) {
		uname = user;
		pword = pass;
		admin = 0;
	}
	
	public String getUsername() {
		return uname;
	}
	
	public String getPassword() {
		return pword;
	}
	
	public int getAdmin() {
		return admin;
	}
	
	public void setAdmin(int i) {
		admin = i;
	}
	
	public void setPassword(String p) {
		pword = p;
	}
	 
	public boolean createAdmin(String uname) {
		if (admin == 1) {
			setAdmin(1);
			return true;
		}
		return false;
	}
	
	public boolean demoteAdmin(String uname) {
		if (admin == 1) {
			setAdmin(0);
			return true;
		}
		return false;
	}
	
	public boolean changePassword(String uname, String newPassword) {
		if (admin == 1) {
			setPassword(newPassword);
			return true;
		}
		return false;
	}
	
	public boolean equals(User u) {
		if (this.uname == u.getUsername()) {
			return true;
		}
		return false;
	}
	
	public long getId() {
		return this.id;
	}
	
	public void setId(long i) {
		this.id = i;
	}
	
	@Override
	public String toString() {
		return uname;
	}
}
